import React from 'react';
import { Form, Icon, Input, Button, Checkbox } from 'antd';
import PropTypes from 'prop-types';
//import { login } from './api/user'

class NormalLoginForm extends React.Component {
    componentDidMount() {
        console.log("enen>>>>????",this.props)
    }
    handleSubmit = e => {
        e.preventDefault();
        this.props.form.validateFields((err, values) => {
            if (!err) {
                this.props.handleSubmit(e.target.value)
            }
        });
    };
    render() {
        const { getFieldDecorator } = this.props.form;
        return (
            <Form onSubmit={this.handleSubmit} className="login-form">
                <h1>用户登录</h1>
                <Form.Item>
                    {getFieldDecorator('username', {
                        rules: [{ required: true, message: 'Please input your username!' }],
                    })(
                        <Input prefix={<Icon type="user" />} placeholder="Username"/>,
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('password', { 
                        rules: [{ required: true, message: 'Please input your Password!' }],
                    })(
                        <Input prefix={<Icon type="lock" />} type="password" placeholder="Password"/>,
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('remember', {
                        valuePropName: 'checked',
                        initialValue: true,
                    })(<Checkbox>Remember me</Checkbox>)}
                        <a className="login-form-forgot" href="##">
                            Forgot password
                        </a>
                        <Button type="primary" htmlType="submit" className="login-form-button">
                            Log in
                        </Button>
                        Or <a href="##">register now!</a>
                </Form.Item>
            </Form>
        );
    }
}
NormalLoginForm.propTypes = {
    handleSubmit:PropTypes.func,//检测函数（Function类型）
 }
const LoginUser = Form.create({ name: 'login' })(NormalLoginForm);

export {LoginUser};